﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;

public partial class Supervise_TraConstractMangeSele : System.Web.UI.Page,HZ.MBSM.BLL.TraDes
{
    string _strProjectIdSel;
    public string _AreaIdSel = "", _AreaId = "530000";
    public string _datagridsql = "";
    string _strAreaNameForm, _strAreaIdForm;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HZ.MBSM.BLL.Login.CheckAssert(this.UseAccountType))
        {

            HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
            if (_Account != null)
            {
                _AreaIdSel = SysFun.IsSQL(SysFun.ToTrim(_Account.AreaId));           
                _strAreaIdForm = SysFun.IsSQL(SysFun.ToTrim(Request.Form["txtAreaId"]));
                if ((DropDownList1.SelectedValue.ToString() == "6") && ((_strAreaIdForm == "530000") || (_strAreaIdForm=="")) && (_AreaIdSel == "530000"))
                {
                    string strSqldb = "SELECT  a.AreaName AS 地区, SUM(CASE WHEN GoodsState = 0 THEN PurchasePrice * Isnull(PlanPurNum, 0) ELSE 0 END) AS 原中标金额,SUM(CASE WHEN GoodsState = 1 THEN PurchasePrice * Isnull(PlanPurNum, 0) ELSE 0 END) AS 自行采购金额,SUM(CASE WHEN GoodsState = 2 THEN PurchasePrice * Isnull(PlanPurNum, 0) ELSE 0 END) AS '22种降价药品',SUM(CASE WHEN GoodsState = 3 THEN PurchasePrice * Isnull(PlanPurNum, 0) ELSE 0 END) AS '血液制品',SUM(CASE WHEN GoodsState = 4 THEN PurchasePrice * Isnull(PlanPurNum, 0) ELSE 0 END) AS '重点监控',SUM(PurchaseTable.PurchasePrice * ISNULL(PurchaseTable.PlanPurNum, 0))  AS 合同总金额 FROM PurchaseTable INNER JOIN Area b ON PurchaseTable.AreaId = b.AreaId INNER JOIN Area a ON LEFT(CONVERT(varchar(255), PurchaseTable.AreaId), 4) + '00' = a.AreaId WHERE (PurchaseTable.State = '正常采购') AND (PurchaseTable.ProjectId = " + listProject.SelectedValue + ") AND (PurchaseTable.AreaId > 530000) AND (PurchaseTable.AreaId < 419900) GROUP BY a.AreaId, a.AreaName, PurchaseTable.ProjectId ORDER BY a.AreaId ";
                    Db dbdb = new Db();
                    DataTable da = dbdb.DataTable(strSqldb);
                    dbdb.Close();
                    GridView1.DataSource = da;
                    GridView1.DataBind();
                    GridView1.Visible = true;
                    Label1.Visible = false;
                    System.Text.StringBuilder strHtmlarea = new System.Text.StringBuilder();
                    _strAreaNameForm = SysFun.ToTrim(Request.Form["txtAreaName"]);
                    _strAreaIdForm = SysFun.ToTrim(Request.Form["txtAreaId"]);
                    if (_strAreaNameForm != "" && _strAreaIdForm != "")
                    {
                        strHtmlarea.Append("<input type='text' name='txtAreaName' value ='" + _strAreaNameForm + "' id='Text1' language='javascript' onclick='return Text1_onclick()'  InvertedComma='所属地区' readonly />");
                        strHtmlarea.Append("<input type='text' name='txtAreaId'  value ='" + _strAreaIdForm + "' style='display: none' />");
                    }
                    else
                    {
                        string strTempAreaId = SysFun.ToTrim(Request.QueryString["AreaId"]);
                        if (strTempAreaId != "")
                        {
                            Db Db1 = new Db();
                            System.Data.IDataReader drArea;
                            string strSql = "select * from area where areaid = " + strTempAreaId;
                            drArea = Db1.DataReader(strSql);
                            while (drArea.Read())
                            {
                                strHtmlarea.Append("<input type='text' name='txtAreaName' value ='" + drArea["AreaName"].ToString() + "' id='Text1' language='javascript' onclick='return Text1_onclick()'  InvertedComma='所属地区' readonly />");
                                strHtmlarea.Append("<input type='text' name='txtAreaId'  value ='" + drArea["AreaId"].ToString() + "' style='display: none' />");
                            }
                            drArea.Close();
                            drArea.Dispose();
                            Db1.Close();
                        }
                        else
                        {
                            strHtmlarea.Append("<input type='text' name='txtAreaName' id='Text1' language='javascript' onclick='return Text1_onclick()'  InvertedComma='所属地区' readonly />");
                            strHtmlarea.Append("<input type='text' name='txtAreaId' style='display: none' />");
                        }
                    }
                    if (_AreaIdSel != "")
                    {
                        strHtmlarea.Append("<a href='javascript:AreaSelect(" + _AreaIdSel + ")'>选择地区</a>");
                    }
                    labArea.Text = strHtmlarea.ToString();

                    labArea.Enabled = true;
                    labArea.Visible = true;
                    if (Request.Form["SumPrint"] == "下载查询内容")
                    {
                        SysFun.WriteToExcel(GridView1, this.Page, "结果.xls"); 
                        //Print();
                    }
                }
                else
                {
                    Label1.Visible = true;
                    GridView1.Visible = false;
                    if (!IsPostBack)
                    {
                        Db db = new Db();
                        string strSql = "select projectid,ProjectMarker,Title from project order by projectid desc";
                        System.Data.IDataReader dr = db.DataReader(strSql);
                        listProject.DataSource = dr; listProject.DataTextField = "Title";
                        listProject.DataValueField = "projectid";
                        listProject.DataBind();
                        dr.Close();
                        dr.Dispose();
                        db.Close();
                    }
                    _strProjectIdSel = listProject.SelectedValue;
                    showGridView();
                    if (Request.Form["SumPrint"] == "下载查询内容")
                    {
                        //showGridView();
                        GridBind();
                    }
                }
            }
           
        }
    }

    public void showGridView()
    {
        int i = 0;
        string j = DropDownList1.SelectedValue.ToString();
        string strConditions = fctConditions();
        string _strsql = "";
        if (j == "6")
        {
            _strsql = "select Sum(Case When GoodsState=0 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS bidprice,Sum(Case When GoodsState=1 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS bakeprice,Sum(Case When GoodsState=2 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS Nolimtprice,Sum(Case When GoodsState=3 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS GMPprice,Sum(Case When GoodsState=4 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS KeyPrice,convert(numeric(30,2),Sum(PurchasePrice*Isnull(PlanPurNum,0))) AS 合同总金额 from PurchaseTable,Area  ";
        }
        else
        {
            _strsql = "select Sum(Case When GoodsState=0 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS bidprice,Sum(Case When GoodsState=1 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS bakeprice,Sum(Case When GoodsState=2 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS Nolimtprice,Sum(Case When GoodsState=3 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS GMPprice,Sum(Case When GoodsState=4 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS KeyPrice,convert(numeric(30,2),Sum(PurchasePrice*Isnull(PlanPurNum,0))) AS 合同总金额 from PurchaseTable,Area";
       
        }
            if (strConditions.Trim().Length > 0)
        {
            _strsql += " where " + strConditions;
        }

        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.GroupHaving = fctGroupHaving();
        if (j == "6")
        {
            dbPage.Table = "PurchaseTable,Area";
        }
        else
        {
            dbPage.Table = "PurchaseTable,Area";
        }
        //dbPage.SelectFieldGroup = "UserCode_TB,CompanyName_TB,UserCode_PS,CompanyName_PS,AccountId_PS,AccountId_TB,AccountId_YY,HospitalName,UserCode_YY,ProjectId,print_state";                                       //要查询的表明
        dbPage.SelectFieldGroup = fctFieldGroup();
        //dbPage.SelectField = "UserCode_TB,CompanyName_TB,UserCode_PS,CompanyName_PS,AccountId_PS,AccountId_TB,AccountId_YY,HospitalName,UserCode_YY,ProjectId,print_state";//要显示的字段
        dbPage.SelectField = fctSelectField();
        //dbPage.Key = "CompanyName_TB,CompanyName_PS,AccountId_PS,AccountId_TB,AccountId_YY,HospitalName,UserCode_YY,ProjectId";                                               //表的主键    
        dbPage.Key = fctKey();
        dbPage.Where = strConditions;                                           //查询条件    
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);         //要显示第几页
        if (Request.Form["SumPrint"] == "下载查询内容")
        { dbPage.PageSize = 100000; }
        else
        { dbPage.PageSize = 20; }                                       //没有显示记录条数   
        //dbPage.OrderBy = "CompanyName_TB,CompanyName_PS,AccountId_PS,AccountId_TB,AccountId_YY,ProjectId,print_state";//排序字段
        dbPage.OrderBy = fctOrderBy();

        System.Text.StringBuilder strHtml = new System.Text.StringBuilder();
        strHtml.Append("<table width='98%' border='0' align='right' cellpadding='2' cellspacing='1'>");
        strHtml.Append("<tr>");
        if (j == "1")
        {
            strHtml.Append("<td width='10%'>医院注册号</td>");
            strHtml.Append("<td width='30%'>医院名称</td>");
            strHtml.Append("<td width='10%'>原中标金额</td>");
            strHtml.Append("<td width='10%'>自行采购金额</td>");
            strHtml.Append("<td width='10%'>22种降价金额</td>");
            strHtml.Append("<td width='10%'>血液制品</td>");
            strHtml.Append("<td width='10%'>重点监控</td>");
            strHtml.Append("<td width='10%'>总金额</td>");
            txtHospitalName.Enabled = true; this.txtHospitalName.Attributes.Add("onkeydown", "if(event.keyCode == 13){document.getElementById('Button1').focus();}");
            txtUserCode_YY.Enabled = true;
            txtCompanyName_TB.Enabled = false; txtCompanyName_TB.Text = "";
            txtUserCode_TB.Enabled = false; txtUserCode_TB.Text = "";
            txtCompanyName_PS.Enabled = false; txtCompanyName_PS.Text = "";
            txtUserCode_PS.Enabled = false; txtUserCode_PS.Text = "";
            txtCompanyName_sc.Enabled = false; txtCompanyName_sc.Text = "";
            txtUserCode_SC.Enabled = false; txtUserCode_SC.Text = "";
            goodsid.Enabled = false; goodsid.Text = "";
            productname.Enabled = false; productname.Text = "";
            labArea.Visible = false; labArea.Text = "";

        }
        else if (j == "2") 
        {
            strHtml.Append("<td width='10%'>中标人注册号</td>");
            strHtml.Append("<td width='30%'>中标人名称</td>");
            strHtml.Append("<td width='10%'>原中标金额</td>");
            strHtml.Append("<td width='10%'>自行采购金额</td>");
            strHtml.Append("<td width='10%'>22种降价金额</td>");
            strHtml.Append("<td width='10%'>血液制品</td>");
            strHtml.Append("<td width='10%'>重点监控</td>");
            strHtml.Append("<td width='10%'>总金额</td>");
            txtHospitalName.Enabled = false; txtHospitalName.Text = "";
            txtUserCode_YY.Enabled = false;txtUserCode_YY.Text="";
            txtCompanyName_TB.Enabled = true;
            txtUserCode_TB.Enabled = true;
            txtCompanyName_PS.Enabled = false; txtCompanyName_PS.Text = "";
            txtUserCode_PS.Enabled = false; txtUserCode_PS.Text = "";
            txtCompanyName_sc.Enabled = false; txtCompanyName_sc.Text = "";
            txtUserCode_SC.Enabled = false; txtUserCode_SC.Text = "";
            goodsid.Enabled = false; goodsid.Text = "";
            productname.Enabled = false; productname.Text = "";
            labArea.Visible = false; labArea.Text = "";


        }
        else if (j == "3") 
        {
            strHtml.Append("<td width='10%'>配送企业注册号</td>");
            strHtml.Append("<td width='30%'>配送企业名称</td>");
            strHtml.Append("<td width='10%'>原中标金额</td>");
            strHtml.Append("<td width='10%'>自行采购金额</td>");
            strHtml.Append("<td width='10%'>22种降价金额</td>");
            strHtml.Append("<td width='10%'>血液制品</td>");
            strHtml.Append("<td width='10%'>重点监控</td>");
            strHtml.Append("<td width='10%'>总金额</td>");
            txtHospitalName.Enabled = false; txtHospitalName.Text = "";
            txtUserCode_YY.Enabled = false; txtUserCode_YY.Text = "";
            txtCompanyName_TB.Enabled = false; txtCompanyName_TB.Text = "";
            txtUserCode_TB.Enabled = false; txtUserCode_TB.Text = "";
            txtCompanyName_PS.Enabled = true;
            txtUserCode_PS.Enabled = true;
            txtCompanyName_sc.Enabled = false; txtCompanyName_sc.Text = "";
            txtUserCode_SC.Enabled = false; txtUserCode_SC.Text = "";
            goodsid.Enabled = false; goodsid.Text = "";
            productname.Enabled = false; productname.Text = "";
            labArea.Visible = false; labArea.Text = "";

        }
        else if (j == "4") 
        {
            strHtml.Append("<td width='10%'>生产企业注册号</td>");
            strHtml.Append("<td width='30%'>生产企业名称</td>");
            strHtml.Append("<td width='10%'>原中标金额</td>");
            strHtml.Append("<td width='10%'>自行采购金额</td>");
            strHtml.Append("<td width='10%'>22种降价金额</td>");
            strHtml.Append("<td width='10%'>血液制品</td>");
            strHtml.Append("<td width='10%'>重点监控</td>");
            strHtml.Append("<td width='10%'>总金额</td>");
            txtHospitalName.Enabled = false; txtHospitalName.Text = "";
            txtUserCode_YY.Enabled = false; txtUserCode_YY.Text = "";
            txtCompanyName_TB.Enabled = false; txtCompanyName_TB.Text = "";
            txtUserCode_TB.Enabled = false; txtUserCode_TB.Text = "";
            txtCompanyName_PS.Enabled = false; txtCompanyName_PS.Text = "";
            txtUserCode_PS.Enabled = false; txtUserCode_PS.Text = "";
            txtCompanyName_sc.Enabled = true;
            txtUserCode_SC.Enabled = true;
            goodsid.Enabled = false; goodsid.Text = "";
            productname.Enabled = false;productname.Text="";
            labArea.Visible = false; labArea.Text = "";

        }
        else if (j == "5")
        {
            strHtml.Append("<td width='10%'>流水号</td>");
            strHtml.Append("<td width='30%'>通用名</td>");
            strHtml.Append("<td width='10%'>规格</td>");
            strHtml.Append("<td width='10%'>剂型</td>");
            strHtml.Append("<td width='10%'>转换系数</td>");
            strHtml.Append("<td width='10%'>质量层次</td>");
            strHtml.Append("<td width='10%'>生产企业</td>");
            strHtml.Append("<td width='10%'>总金额</td>");
            goodsid.Enabled = true;
            productname.Enabled = true;
            txtCompanyName_TB.Enabled = false; txtCompanyName_TB.Text = "";
            txtUserCode_TB.Enabled = false; txtUserCode_TB.Text = "";
            txtCompanyName_PS.Enabled = false; txtCompanyName_PS.Text = "";
            txtUserCode_PS.Enabled = false; txtUserCode_PS.Text = "";
            txtHospitalName.Enabled = false; txtHospitalName.Text = "";
            txtUserCode_YY.Enabled = false; txtUserCode_YY.Text = "";
            txtCompanyName_sc.Enabled = false; txtCompanyName_sc.Text = "";
            txtUserCode_SC.Enabled = false; txtUserCode_SC.Text = "";
            ddl_money.Enabled = false;
            labArea.Visible = false; labArea.Text = "";

           
            
        }
        else if (j == "6") //按地区查询

        {
            System.Text.StringBuilder strHtmlarea = new System.Text.StringBuilder();
            _strAreaNameForm = SysFun.ToTrim(Request.Form["txtAreaName"]);
            _strAreaIdForm = SysFun.ToTrim(Request.Form["txtAreaId"]);
            if (_strAreaNameForm != "" && _strAreaIdForm != "")
            {

                strHtmlarea.Append("<input type='text' name='txtAreaName' value ='" + _strAreaNameForm + "' id='Text1' language='javascript' onclick='return Text1_onclick()'  InvertedComma='所属地区' readonly />");
                strHtmlarea.Append("<input type='text' name='txtAreaId'  value ='" + _strAreaIdForm + "' style='display: none' />");
            }
            else
            {
                string strTempAreaId = SysFun.ToTrim(Request.QueryString["AreaId"]);
                if (strTempAreaId != "")
                {
                    Db Db1 = new Db();
                    System.Data.IDataReader drArea;
                    string strSql = "select * from area where areaid = " + strTempAreaId;
                    drArea = Db1.DataReader(strSql);
                    while (drArea.Read())
                    {
                        strHtmlarea.Append("<input type='text' name='txtAreaName' value ='" + drArea["AreaName"].ToString() + "' id='Text1' language='javascript' onclick='return Text1_onclick()'  InvertedComma='所属地区' readonly />");
                        strHtmlarea.Append("<input type='text' name='txtAreaId'  value ='" + drArea["AreaId"].ToString() + "' style='display: none' />");

                    }
                    drArea.Close();
                    drArea.Dispose();
                    Db1.Close();
                }
                else
                {
                    strHtmlarea.Append("<input type='text' name='txtAreaName' id='Text1' language='javascript' onclick='return Text1_onclick()'  InvertedComma='所属地区' readonly />");
                    strHtmlarea.Append("<input type='text' name='txtAreaId' style='display: none' />");
                }           
            }
            if (_AreaIdSel != "")
            {
                strHtmlarea.Append("<a href='javascript:AreaSelect(" + _AreaIdSel + ")'>选择地区</a>");
            }
            labArea.Text = strHtmlarea.ToString();
           
                labArea.Enabled = true;
                labArea.Visible = true;
                Label1.Visible = true;
 
            strHtml.Append("<td width='20%'>地区</td>");
            strHtml.Append("<td width='10%'>原中标金额</td>");
            strHtml.Append("<td width='10%'>自行采购金额</td>");
            strHtml.Append("<td width='10%'>22种降价金额</td>");
            strHtml.Append("<td width='10%'>血液制品</td>");
            strHtml.Append("<td width='10%'>重点监控</td>");
            strHtml.Append("<td width='10%'>总金额</td>");
            txtHospitalName.Enabled = false; txtHospitalName.Text = "";
            txtUserCode_YY.Enabled = false; txtUserCode_YY.Text = "";
            txtCompanyName_TB.Enabled = false; txtCompanyName_TB.Text = "";
            txtUserCode_TB.Enabled = false; txtUserCode_TB.Text = "";
            txtCompanyName_PS.Enabled = false; txtCompanyName_PS.Text = "";
            txtUserCode_PS.Enabled = false; txtUserCode_PS.Text = "";
            txtCompanyName_sc.Enabled = false; txtCompanyName_sc.Text = "";
            txtUserCode_SC.Enabled = false; txtUserCode_SC.Text = "";
            goodsid.Enabled = false; goodsid.Text = "";
            productname.Enabled = false; productname.Text = "";   
         
        }

        strHtml.Append("</tr>");
        System.Data.IDataReader dr = dbPage.ExecuteReaderGroup(60);
        if (Request.Form["SumPrint"] == "下载查询内容")
        {
            _datagridsql = dbPage.Sql;
        }
        while (dr.Read())
        {
            if (i == 0)
            {
                strHtml.Append("<tr class='table_td'>");
                i++;
            }
            else
            {
                strHtml.Append("<tr class='table_td2'>");
                i--;
            }
            if (j == "1")//医院
            {
                strHtml.Append("<td> " + dr["医院注册号"].ToString() + " </td>");
                strHtml.Append("<td> " + dr["医院名称"].ToString() + " </td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=" + dr["AccountId_YY"].ToString() + "&AccountId_TB=&AccountId_PS=&AccountId_SC=&ProjectId=" + _strProjectIdSel + "&State=0' target='_blank'>" + dr["原中标金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=" + dr["AccountId_YY"].ToString() + "&AccountId_TB=&AccountId_PS=&AccountId_SC=&ProjectId=" + _strProjectIdSel + "&State=1' target='_blank'>" + dr["自行采购金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=" + dr["AccountId_YY"].ToString() + "&AccountId_TB=&AccountId_PS=&AccountId_SC=&ProjectId=" + _strProjectIdSel + "&State=2' target='_blank'>" + dr["22种降价金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=" + dr["AccountId_YY"].ToString() + "&AccountId_TB=&AccountId_PS=&AccountId_SC=&ProjectId=" + _strProjectIdSel + "&State=2' target='_blank'>" + dr["血液制品金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=" + dr["AccountId_YY"].ToString() + "&AccountId_TB=&AccountId_PS=&AccountId_SC=&ProjectId=" + _strProjectIdSel + "&State=2' target='_blank'>" + dr["重点监控金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Hospital/PrintPurList.Aspx?HospitalName=" + dr["医院名称"] + "&AccountId_YY=" + dr["AccountId_YY"].ToString() + "&AccountId_TB=&AccountId_PS=&AccountId_SC=&ProjectId=" + _strProjectIdSel + "' target='_blank'>" + dr["合同总金额"].ToString() + "</td>");
            }
            else if (j == "2")//中标人

            {
                strHtml.Append("<td> " + dr["投标人注册号"].ToString() + " </td>");
                strHtml.Append("<td><a href='../agency/company_xq.aspx?&Accountid_PS=" + dr["AccountId_TB"].ToString() + "' target='_blank'>" + dr["投标人名称"].ToString() + "</a></td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=" + dr["AccountId_TB"].ToString() + "&AccountId_PS=&AccountId_SC=&ProjectId=" + _strProjectIdSel + "&State=0' target='_blank'>" + dr["原中标金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=" + dr["AccountId_TB"].ToString() + "&AccountId_PS=&AccountId_SC=&ProjectId=" + _strProjectIdSel + "&State=1' target='_blank'>" + dr["自行采购金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=" + dr["AccountId_TB"].ToString() + "&AccountId_PS=&AccountId_SC=&ProjectId=" + _strProjectIdSel + "&State=2' target='_blank'>" + dr["22种降价金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=" + dr["AccountId_TB"].ToString() + "&AccountId_PS=&AccountId_SC=&ProjectId=" + _strProjectIdSel + "&State=2' target='_blank'>" + dr["血液制品金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=" + dr["AccountId_TB"].ToString() + "&AccountId_PS=&AccountId_SC=&ProjectId=" + _strProjectIdSel + "&State=2' target='_blank'>" + dr["重点监控金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=" + dr["AccountId_TB"].ToString() + "&AccountId_PS=&AccountId_SC=&Goodsid=&AreaId&ProjectId=" + _strProjectIdSel + "&State=3' target='_blank'>" + dr["合同总金额"].ToString() + "</td>");
            }
            else if (j == "3")//配送企业

            {
                strHtml.Append("<td>" + dr["配送企业注册号"].ToString() + " </td>");
                strHtml.Append("<td><a href='../agency/company_xq.aspx?&Accountid_PS=" + dr["AccountId_PS"].ToString() + "' target='blank' target='_blank'>" + dr["配送企业名称"].ToString() + "</a></td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=&AccountId_PS=" + dr["AccountId_PS"].ToString() + "&AccountId_SC=&ProjectId=" + _strProjectIdSel + "&State=0' target='_blank'>" + dr["原中标金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=&AccountId_PS=" + dr["AccountId_PS"].ToString() + "&AccountId_SC=&ProjectId=" + _strProjectIdSel + "&State=1' target='_blank'>" + dr["自行采购金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=&AccountId_PS=" + dr["AccountId_PS"].ToString() + "&AccountId_SC=&ProjectId=" + _strProjectIdSel + "&State=2' target='_blank'>" + dr["22种降价金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=&AccountId_PS=" + dr["AccountId_PS"].ToString() + "&AccountId_SC=&ProjectId=" + _strProjectIdSel + "&State=2' target='_blank'>" + dr["血液制品金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=&AccountId_PS=" + dr["AccountId_PS"].ToString() + "&AccountId_SC=&ProjectId=" + _strProjectIdSel + "&State=2' target='_blank'>" + dr["重点监控金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=&AccountId_PS=" + dr["AccountId_PS"].ToString() + "&AccountId_SC=&Goodsid=&AreaId&ProjectId=" + _strProjectIdSel + "&State=3' target='_blank'>" + dr["合同总金额"].ToString() + "</td>");
            }
            else if (j == "4") //生产企业
            {
                strHtml.Append("<td>" + dr["生产企业注册号"].ToString() + " </td>");
                strHtml.Append("<td><a href='../agency/company_xq.aspx?&Accountid_PS=" + dr["AccountId_SC"].ToString() + "' target='blank' target='_blank'>" + dr["生产企业名称"].ToString() + "</a></td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=&AccountId_PS=&AccountId_SC=" + dr["AccountId_SC"].ToString() + "&ProjectId=" + _strProjectIdSel + "&State=0' target='_blank'>" + dr["原中标金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=&AccountId_PS=&AccountId_SC=" + dr["AccountId_SC"].ToString() + "&ProjectId=" + _strProjectIdSel + "&State=1' target='_blank'>" + dr["自行采购金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=&AccountId_PS=&AccountId_SC=" + dr["AccountId_SC"].ToString() + "&ProjectId=" + _strProjectIdSel + "&State=2' target='_blank'>" + dr["22种降价金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=&AccountId_PS=&AccountId_SC=" + dr["AccountId_SC"].ToString() + "&ProjectId=" + _strProjectIdSel + "&State=2' target='_blank'>" + dr["血液制品金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=&AccountId_PS=&AccountId_SC=" + dr["AccountId_SC"].ToString() + "&ProjectId=" + _strProjectIdSel + "&State=2' target='_blank'>" + dr["重点监控金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=&AccountId_PS=&AccountId_SC=" + dr["AccountId_SC"].ToString() + "&Goodsid=&AreaId&ProjectId=" + _strProjectIdSel + "&State=3' target='_blank'>" + dr["合同总金额"].ToString() + "</td>");
            }
            else if (j == "5") //药品
            {
                strHtml.Append("<td>" + dr["流水号"].ToString() + " </td>");
                strHtml.Append("<td>" + dr["通用名"].ToString() + "</td>");
                strHtml.Append("<td>" + dr["规格"].ToString() + "</td>");
                strHtml.Append("<td>" + dr["剂型"].ToString() + "</td>");
                strHtml.Append("<td>" + dr["转换系数"].ToString() + "</td>");
                strHtml.Append("<td>" + dr["质量层次"].ToString() + "</td>");
                strHtml.Append("<td>" + dr["生产企业"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=&AccountId_PS=&AccountId_SC=&Goodsid=" + dr["流水号"].ToString() + "&AreaId&ProjectId=" + _strProjectIdSel + "&State=3' target='_blank'>" + dr["合同总金额"].ToString() + "</td>");
            }
           else if (j == "6")//地区
            {
                strHtml.Append("<td> " + dr["地区"].ToString() + " </td>");
                strHtml.Append("<td>" + dr["原中标金额"].ToString() + "</td>");
                strHtml.Append("<td>" + dr["自行采购金额"].ToString() + "</td>");
                strHtml.Append("<td>" + dr["22种降价金额"].ToString() + "</td>");
                strHtml.Append("<td>" + dr["血液制品金额"].ToString() + "</td>");
                strHtml.Append("<td>" + dr["重点监控金额"].ToString() + "</td>");
                strHtml.Append("<td><a href='../Supervise/TraContractMangeDetail.Aspx?&AccountId_YY=&AccountId_TB=&AccountId_PS=&AccountId_SC=&Goodsid=&AreaId=" + dr["AreaId"].ToString() + "&ProjectId=" + _strProjectIdSel + "&State=3' target='_blank'>" + dr["合同总金额"].ToString() + "</td>");
            }
            //strHtml.Append("<td><a href='../Hospital/Print.aspx?AccountId_YY=" + dr["AccountId_YY"].ToString() + "&CompanyName_TB=" + dr["CompanyName_TB"].ToString() + "&AccountId_TB=" + dr["AccountId_TB"].ToString() + "&AccountId_PS=" + dr["AccountId_PS"].ToString() + "&CompanyName_PS=" + dr["CompanyName_PS"].ToString() + "&Projectid=" + _strProjectIdSel + "' target='_blank' >查看合同</a>");
            //if ((dr["print_state"]).ToString() != "")
            //{
            //    strHtml.Append("<td><a href='../Hospital/PrintPurList.aspx?HospitalName=" + dr["HospitalName"].ToString() + "&AccountId_YY=" + dr["AccountId_YY"].ToString() + "&AccountId_TB=" + dr["AccountId_TB"].ToString() + "&Accountid_PS=" + dr["AccountId_PS"].ToString() + "&ProjectId=" + _strProjectIdSel + "' target='_blank' title='已打印'><font color= red>查看合同附表</font></a>");
            //}
            //else
            //{
            //    strHtml.Append("<td><a href='../Hospital/PrintPurList.aspx?HospitalName=" + dr["HospitalName"].ToString() + "&AccountId_YY=" + dr["AccountId_YY"].ToString() + "&AccountId_TB=" + dr["AccountId_TB"].ToString() + "&Accountid_PS=" + dr["AccountId_PS"].ToString() + "&ProjectId=" + _strProjectIdSel + "' target='_blank' title='未打印'>查看合同附表</a>");
            //}

            strHtml.Append("</tr>");
        }
        
        strHtml.Append("</table>");
        Label1.Text = strHtml.ToString();
        dr.Close();
        dr.Dispose();
        dr = db.DataReader(_strsql);
        Label2.ForeColor = System.Drawing.Color.Red;
        Label2.Text = "原中标金额：0  自行采购金额：0 22种降价金额：0 血液制品金额：0 重点监控金额：0 合同总金额： 0";
        if (dr.Read())
        {
            if (j == "5")
            {
                Label2.Text = "";
                Label2.Text += "   合同总金额： " + dr["合同总金额"].ToString();
            }
            else
            {
                Label2.Text = "";
                Label2.Text += "原中标金额： " + dr["bidprice"].ToString();
                Label2.Text += "   自行采购金额： " + dr["bakeprice"].ToString();   
                Label2.Text += "   22种降价金额： " + dr["Nolimtprice"].ToString();
                Label2.Text += "   血液制品金额： " + dr["GMPprice"].ToString();
                Label2.Text += "   重点监控金额： " + dr["KeyPrice"].ToString();
                Label2.Text += "   合同总金额： " + dr["合同总金额"].ToString();
            }
        }
        dr.Close();
        dr.Dispose();

        dbPage.Db.Close();
        db.Close();
        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键

    }

    private String fctGroupHaving()
    {
        string strHaving = "";
        switch (ddl_money.SelectedValue.ToString())
        {
            case "0":
                break;
            case "1"://总金额

                strHaving = " Sum(PurchasePrice*Isnull(PlanPurNum,0))=0 ";
                break;
            case "2"://原中标

                strHaving = " Sum(Case When GoodsState=0 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End)=0 ";
                break;
            case "3"://备案采购
                strHaving = " Sum(Case When GoodsState=1 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End)=0 ";
                break;
            case "4"://不限不竞
                strHaving = " Sum(Case When GoodsState=2 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End)=0 ";
                break;
        }
        return strHaving;
    }

    private string fctOrderBy()
    {
        String _strOrderBy = "";
     
       switch (DropDownList1.SelectedValue.ToString())
        {
            
            case "1":
                _strOrderBy = "AccountId_YY,医院名称,医院注册号,ProjectId ";
                break;
            case "2":
                _strOrderBy = "投标人注册号,投标人名称,AccountId_TB,项目号 ";
                break;
            case "3":
                _strOrderBy = "配送企业注册号,配送企业名称,AccountId_PS,项目号 ";
                break;
            case "4":
                _strOrderBy = "AccountId_SC,生产企业名称,生产企业注册号,项目号 ";
                break;
            case "5":
                _strOrderBy = "流水号,通用名,项目号 ";
                break;
            case "6":
                _strOrderBy = " 地区,ProjectId ";
                break;
        }
        return _strOrderBy;
    }

    private string fctKey()
    {
        String _strKey = "";
        switch (DropDownList1.SelectedValue.ToString())
        {
            case "1":
                _strKey = "AccountId_YY,HospitalName,UserCode_YY,ProjectId ";
                break;
            case "2":
               _strKey = "UserCode_TB,CompanyName_TB,AccountId_TB,ProjectId ";
               // _strKey = "投标人注册号,投标人名称,AccountId_TB,项目号 ";
                break;
            case "3":
                _strKey = "UserCode_PS,CompanyName_PS,AccountId_PS,ProjectId ";
               // _strKey = "配送企业注册号,配送企业名称,AccountId_PS,项目号 ";
                break;
            case "4":
                _strKey = "AccountId_SC,CompanyName_SC,UserCode_SC,ProjectId ";
                //_strKey = "AccountId_SC,CompanyName_SC,UserCode_SC,ProjectId ";
                break;
            case "5":
                _strKey = "goodsid,productname,ProjectId ";
                break;
            case "6":
                _strKey = " AreaName,PurchaseTable.AreaId,ProjectId ";
                break;
        }
        return _strKey;
    }

    private string fctSelectField()
    {
        String _strSelecctField = "";
       
        switch (DropDownList1.SelectedValue.ToString())
        {
            case "1":
                _strSelecctField = "AccountId_YY,HospitalName  as 医院名称,UserCode_YY  AS 医院注册号,ProjectId,Sum(Case When GoodsState=0 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS 原中标金额,Sum(Case When GoodsState=1 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS 自行采购金额,Sum(Case When GoodsState=2 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS '22种降价金额',Sum(Case When GoodsState=3 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS '血液制品金额',Sum(Case When GoodsState=4 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS '重点监控金额',Sum(PurchasePrice*Isnull(PlanPurNum,0)) AS 合同总金额 ";

                break;
            case "2":
                _strSelecctField = "UserCode_TB as 投标人注册号,CompanyName_TB as  投标人名称,AccountId_TB,ProjectId as 项目号,Sum(Case When GoodsState=0 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS 原中标金额,Sum(Case When GoodsState=1 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS 自行采购金额,Sum(Case When GoodsState=2 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS '22种降价金额',Sum(Case When GoodsState=3 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS '血液制品金额',Sum(Case When GoodsState=4 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS '重点监控金额',Sum(PurchasePrice*Isnull(PlanPurNum,0)) AS 合同总金额 ";
                break;
            case "3":
                _strSelecctField = "UserCode_PS as 配送企业注册号,CompanyName_PS as 配送企业名称,AccountId_PS,ProjectId as 项目号,Sum(Case When GoodsState=0 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS 原中标金额,Sum(Case When GoodsState=1 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS 自行采购金额,Sum(Case When GoodsState=2 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS '22种降价金额',Sum(Case When GoodsState=3 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS '血液制品金额',Sum(Case When GoodsState=4 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS '重点监控金额',Sum(PurchasePrice*Isnull(PlanPurNum,0)) AS 合同总金额 ";
                break;
            case "4":
                _strSelecctField = "AccountId_SC ,CompanyName_SC as 生产企业名称,UserCode_SC as 生产企业注册号,ProjectId as 项目号,Sum(Case When GoodsState=0 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS 原中标金额,Sum(Case When GoodsState=1 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS 自行采购金额,Sum(Case When GoodsState=2 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS '22种降价金额',Sum(Case When GoodsState=3 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS '血液制品金额',Sum(Case When GoodsState=4 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS '重点监控金额',Sum(PurchasePrice*Isnull(PlanPurNum,0)) AS 合同总金额 ";
                break;
            case "5":
                _strSelecctField = "goodsid as 流水号,productname as 通用名,outlookc as 规格,MedicineModel as 剂型,factor as 转换系数 ,CASE QualityLevels " + ConfigurationManager.AppSettings["QualityLevels"].ToString() + " END AS 质量层次,companyname_sc as 生产企业,ProjectId as 项目号,Sum(PurchasePrice*Isnull(PlanPurNum,0)) AS 合同总金额 ";
                break;
            case "6": //按地区查询

                _strSelecctField = "AreaName as 地区,PurchaseTable.AreaId,ProjectId,Sum(Case When GoodsState=0 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS 原中标金额,Sum(Case When GoodsState=1 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS 自行采购金额,Sum(Case When GoodsState=2 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS '22种降价金额',Sum(Case When GoodsState=3 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS '血液制品金额',Sum(Case When GoodsState=4 Then PurchasePrice*Isnull(PlanPurNum,0) Else 0 End) AS '重点监控金额',Sum(PurchasePrice*Isnull(PlanPurNum,0)) AS 合同总金额 ";
                break;
        }
        return _strSelecctField;
    }

    public string fctFieldGroup()
    {
        String _strFieldGroup="";
        switch (DropDownList1.SelectedValue.ToString()) 
        {
            case "1":
                _strFieldGroup = "AccountId_YY,HospitalName,UserCode_YY,ProjectId ";
                break;
            case "2":
                _strFieldGroup = "UserCode_TB,CompanyName_TB,AccountId_TB,ProjectId ";
                break;
            case "3":
                _strFieldGroup = "UserCode_PS,CompanyName_PS,AccountId_PS,ProjectId ";
                break;
            case "4":
                _strFieldGroup = "AccountId_SC,CompanyName_SC,UserCode_SC,ProjectId ";
                break;
            case "5":
                _strFieldGroup = "goodsid,productname,Outlookc,MedicineModel,factor,QualityLevels,CompanyName_SC,ProjectId ";
                break;
            case "6":
                _strFieldGroup = " AreaName,PurchaseTable.AreaId,ProjectId ";
                break;
        }
        return _strFieldGroup;
    }


    public string fctConditions()
    {

        string _strTemp = "";
     //  if (DropDownList1.SelectedValue.ToString() == "6")
       // {
            _strTemp = " State='正常采购' and ProjectId=" + _strProjectIdSel + " And Area.AreaId=PurchaseTable.AreaId and";
            //地区
            if ((_strAreaIdForm != "") && (_strAreaIdForm != null))
            {
                int _intAreaid = SysFun.ToInt(_strAreaIdForm), _intAreaIdMax = 0;
                string _strWhere = "";
                if (_intAreaid != 530000)
                {
                    if (_intAreaid % 100 > 0)
                    {
                        _strTemp += "   PurchaseTable.areaid=" + _intAreaid.ToString() + " and";
                        // Select * From Area Where AreaId % 100 = 0 And AreaId>530000 And AreaId<419900

                    }
                    else
                    {
                        _intAreaIdMax = _intAreaid + 100;
                        _strTemp += " PurchaseTable.areaid>=" + _intAreaid.ToString() + " And PurchaseTable.AreaId< " + _intAreaIdMax.ToString() + " and";
                    }
                }
                else
                {
                    _strTemp += " PurchaseTable.areaid>530000 And PurchaseTable.AreaId< 419900 and";
                }
            }
            else //监督部门权限
            {
                int _intAreaid = SysFun.ToInt(_AreaIdSel), _intAreaIdMax = 0;
                string _strWhere = "";
                if (_intAreaid != 530000)
                {
                    if (_intAreaid % 100 > 0)
                    {
                        _strTemp += "   PurchaseTable.areaid=" + _intAreaid.ToString() + " and";
                    }
                    else
                    {
                        _intAreaIdMax = _intAreaid + 100;
                        _strTemp += " PurchaseTable.areaid>=" + _intAreaid.ToString() + " And PurchaseTable.AreaId< " + _intAreaIdMax.ToString() + " and";
                    }
                }
                else
                {
                    _strTemp += " PurchaseTable.areaid>530000 And PurchaseTable.AreaId< 419900 and";
                }
            }
      //  }
        //else
        //{
        //    _strTemp = " State='正常采购' and ProjectId=" + _strProjectIdSel + " And";
        //}

        //投标人名称

        string _strCompanyName_TB = this.txtCompanyName_TB.Text.Trim().ToString();
        if (_strCompanyName_TB != "")
        {
            _strTemp += " CompanyName_TB like '%" + _strCompanyName_TB + "%' and";
        }
        //投标人编码

        string _strUserCode_TB = this.txtUserCode_TB.Text.Trim().ToString();
        if (_strUserCode_TB != "")
        {
            _strTemp += " UserCode_TB like '%" + _strUserCode_TB + "%' and";
        }

        //配送企业名称

        string _strCompanyName_PS = this.txtCompanyName_PS.Text.Trim().ToString();
        if (_strCompanyName_PS != "")
        {
            _strTemp += " CompanyName_PS like '%" + _strCompanyName_PS + "%' and";
        }

        //配送企业编码

        string _strUserCode_PS = this.txtUserCode_PS.Text.Trim().ToString();
        if (_strUserCode_PS != "")
        {
            _strTemp += " UserCode_PS like '%" + _strUserCode_PS + "%' and";
        }
        //医院名称
        string _strHospitalName = this.txtHospitalName.Text.Trim().ToString();
        if (_strHospitalName != "")
        {
            _strTemp += "  HospitalName like '%" + _strHospitalName + "%' and";
        }

        //医院编码
        string _strUserCode_YY = this.txtUserCode_YY.Text.Trim().ToString();
        if (_strUserCode_YY != "")
        {
            _strTemp += " UserCode_YY like '%" + _strUserCode_YY + "%' and";
        }
        //生产企业名称
        string _strCompanyName_sc = this.txtCompanyName_sc.Text.Trim().ToString();
        if (_strCompanyName_sc != "")
        {
            _strTemp += " CompanyName_sc  like '%" + _strCompanyName_sc + "%' and";
        }
        //生产企业编码
        string _strUserCode_SC = this.txtUserCode_SC.Text.Trim().ToString();
        if (_strUserCode_SC != "")
        {
            _strTemp += " UserCode_SC like '%" + _strUserCode_SC + "%' and";
        }
        //流水号

        string _strGoodsid = goodsid.Text.Trim();
        if (_strGoodsid != "")
        {
            _strTemp += " goodsid =" + _strGoodsid + " and";
        }
        //通用名

        string _strProductname = productname.Text.Trim();
        if (_strProductname != "")
        {
            _strTemp += " (productname like '%" + _strProductname + "%' or Product_SpellingCode like'%" + _strProductname + "%') and";
        }
        if (_strTemp != "")
        {
            _strTemp = "  " + _strTemp.Substring(0, _strTemp.Length - 3);
        }

        return _strTemp;
    }

    #region TraDes 成员

    public string Name
    {
        get { return "合同管理查询"; }
    }

    public string Describe
    {
        get { return ""; }
    }

    public string ParentName
    {
        get { return "合同管理"; }
    }

    public System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> UseAccountType
    {
        get
        {
            System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAdmin);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumSupervise);
            return _AccountType;
        }
    }

    #endregion
    public void Print()
    {
        Response.Clear();
        Response.Buffer = true;
        Response.Charset = "GB2312";
        // 添加头信息，为"文件下载/另存为"对话框指定默认文件名 
        Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode("文件.xls"));

        Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
        Response.ContentEncoding = System.Text.Encoding.UTF7;  //解决将gridview导出成excel时出现乱码  

        Response.ContentType = "application/ms-excel";
        this.EnableViewState = false;
        System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
        GridView1.Visible = true;
        this.GridView1.RenderControl(oHtmlTextWriter);

        // 把文件流发送到客户端 
        Response.Write(oStringWriter.ToString());
        // 停止页面的执行


        Response.End();
    }

 
    public override void VerifyRenderingInServerForm(Control control)
    {
        //OverRide　为了使导出成Excel可行！

    }
    public void GridBind() 
    {
        Db db = new Db();
        System.Data.IDataReader dr;
        string sql = _datagridsql.Replace("Select   Top 100000 AccountId_YY,HospitalName,UserCode_YY,ProjectId", "Select HospitalName as 医院名称,UserCode_YY AS 医院注册号");
        dr = db.DataReader(sql);
        this.GridView1.DataSource = dr;
        this.GridView1.DataBind();
        db.Close();
        dr.Close();
        dr.Dispose();
        showGridView();
        SysFun.WriteToExcel(GridView1, this.Page, "结果.xls");

    }
    protected void Button1_Click(object sender, EventArgs e)
    {

    }
}
